package com.example.demo.controller;

import com.example.demo.mapper.UserMapper;
import com.example.demo.model.UserInfo;
import com.example.demo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private TestService testService;

    @RequestMapping("/get_all")
    public List<UserInfo> getAll() {
        return testService.getAll();
    }

    @RequestMapping("/add")
    @Transactional
    public int add() {
        UserInfo userInfo = new UserInfo();
        userInfo.setUsername("老七");
        userInfo.setPassword("123456");
        int ret = testService.add(userInfo) + testService.insert(userInfo);
        return 1 / 0;
    }


}
